import csv, sqlite3
import os.path
from Cheetah.Template import Template

conn = sqlite3.connect("c:\\users\ikbhal\\mycrawling\\watchcartoononline\\wco.sqlite")
curs = conn.cursor()
#sqlstatement = "SELECT * from wco limit 1"
sqlstatement = "SELECT * from wco"
#sqlstatement = "SELECT count(*) from wco"
#sqlstatement = "SELECT * from wco"
curs.execute(sqlstatement)
records = curs.fetchall()
#synonyms,episodeListUrl,episodeStory,url,video,episodeTitle,episodeListName
keys = ['synonyms','episodeListUrl','episodeStory','url','video','episodeTitle','episodeListName']
r =0
searchLists= []
episodeTitles=[]
episodeStories =[]
episodeVideos =[]
episodeSynonyms = []
episodeListNames=[]
while r<len(records):
	episodeSynonyms.append(records[r][0])
	episodeStories.append(records[r][2])
	episodeVideos.append(records[r][4])
	episodeTitles.append(records[r][5])
	episodeListNames.append(records[r][6])
	
searchLists =[{'synonyms':episodeSynonyms,'episodeStory':episodeStories,
				'video':episodeVideos, 'episodeTitle':episodeTitles,
				'episodeListName':episodeListNames}]	
result = Template ( file = 'movie.tmpl', searchList =
searchLists )	

file ( 'movie.html', 'w' ).write ( str(result) )